import React, { Component, PropTypes } from 'react'
import AuditApplicationDetail from '../audit-application-detail'

class SlideExpenseReportDetailBar extends Component {

  afterClose = refresh => {
    if(refresh) {
      this.props.afterCheckOrAuto(refresh);
    }
  };

  static contextTypes = {
    info: PropTypes.object,
    form: PropTypes.object,
    invoiceEnabled: PropTypes.bool,
    approvalHistory: PropTypes.array,
    isAuditInApproveStatus: PropTypes.bool,
    isWaitForAudit: PropTypes.bool
  };

  render() {
    const {
      goBack, selectedExpense, selectedInvoice, failedInvoices, expenseReportInvoices, onSelectExpense
    } = this.props;
    const { info, invoiceEnabled, approvalHistory, isAuditInApproveStatus, isWaitForAudit, form } = this.context;
    return <AuditApplicationDetail
      info={info}
      formOID={info.formOID}
      isAuditInApproveStatus={isAuditInApproveStatus}
      entityOID={info.expenseReportOID}
      status={info.status}
      companyOid={info.docCompanyOID}
      applicantOID={info.applicantOID}
      entityType={1002}
      goBack={goBack}
      customFormPropertyMap={form.customFormPropertyMap}
      expenseOid={info.expenseReportOID}
      businessCode={info.businessCode}
      afterClose={this.afterClose}
      invoiceEnabled={invoiceEnabled}
      approvalHistory={approvalHistory}
      fullWidth
      selectedExpense={selectedExpense || []}
      selectedInvoice={selectedInvoice || []}
      expenseReportInvoices={expenseReportInvoices}
      failedInvoices={failedInvoices}
      isWaitForAudit={isWaitForAudit}
      onSelectExpense={onSelectExpense}
    />
  }

}

export default SlideExpenseReportDetailBar;
